//
//  CalendarViewController.m
//  School+
//
//  Created by Sean Sebastian on 5/20/16.
//  Copyright © 2016 Sean Sebastian. All rights reserved.
//

#import "CalendarViewController.h"
#import "DayButton.h"
#import "DDCalendarView.h"

@interface CalendarViewController ()

@end

@implementation CalendarViewController


- (void)dayButtonPressed:(DayButton *)button {
    //For the sake of example, we obtain the date from the button object
    //and display the string in an alert view
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setTimeStyle:NSDateFormatterNoStyle];
    [dateFormatter setDateStyle:NSDateFormatterLongStyle];
    NSString *theDate = [dateFormatter stringFromDate:button.buttonDate];
    
    UIAlertView *dateAlert = [[UIAlertView alloc]
                              initWithTitle:@"Date Pressed"
                              message:theDate
                              delegate:self
                              cancelButtonTitle:@"Ok"
                              otherButtonTitles:nil];
    [dateAlert show];
}

- (void)nextButtonPressed {
    NSLog(@"Next...");
}

- (void)prevButtonPressed {
    NSLog(@"Prev...");
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(backClick)];
    [self.view addSubview: self.calendarView];
}

- (void)backClick
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (DDCalendarView *)calendarView
{
    if (_calendarView == nil) {
        DDCalendarView *view =[[DDCalendarView alloc] initWithFrame:self.view.bounds fontName:@"AmericanTypewriter" delegate:self];
        _calendarView = view;
        return view;
    }
    return _calendarView;
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


@end
